<!DOCTYPE html>
<html lang="en" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>服务商信息</title>
    <header th:replace="header::html"></header>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row  layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form  layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="uname" placeholder="请输入雇主名字" autocomplete="off"
                                   class="layui-input">
                        </div>
                        <div class="layui-input-inline">
                            <select name="typeUser" id="typeUser" onclick="getChildren(this)" >
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="search"><i
                                    class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>

                <div class="layui-card-body ">
                    <table class="layui-hide" id="user-name-label" lay-filter="user-name-label"></table>
                </div>

                <div class="layui-card-body ">
                    <script type="text/html" id="barDemo">
                        <a class="layui-btn layui-btn-xs" lay-event="verify"
                        >进入聊天室</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
	layui.use('table', function () {
		var table = layui.table,
			form = layui.form;
		table.render({
			elem: '#user-name-label'
			, url: '/api-front/employer/getFrontServiceList' //数据接口
			, page: true //开启分页
			, limit: 6
			, response: {
				dataName: 'datas' //规定数据列表的字段名称，默认：data
			}
			, cols: [
				[ //表头
					{title:'序号',type:'numbers',width:'5%'}
					// {type: 'checkbox', fixed: 'left'},
					,{field: 'uid', title: 'ID', align: 'center',hide:true}
					, {field: 'uaccount', title: '账号',width:'13%'}
					, {field: 'uname', title: '昵称',width:'12%'}
					, {field: 'uphone', title: '联系方式',width:'12%'}
					, {field: 'uscore', title: '信用',align: 'center',sort:true,width:'7%'}
					, {field: 'uaddress', title: '地址',width:'15%'}
					, {field: 'usex', title: '性别',align: 'center',width:'5%'}
					, {field: 'tips1', title: '状态',width:'8%',align: 'center'}
					, {field: 'tips2', title: '类型',width:'8%',align: 'center'}
					, {title: '操作', toolbar: '#barDemo',width:'22%',align: 'center'}
				]
			]
			// done: function () {
			// 	//checkPermission();
			// }

		});

		//监听工具条
		table.on('tool(user-name-label)', function (obj) {

			var data = obj.data;//获取点击行数据
			if (obj.event ==='verify') {
				window.parent.parent.location.href="/api-front/chat/service-list";

			}
		});



//搜索
		form.on('submit(search)', function (data) {
			var uname = data.field.uname;
			var sid=$("#typeUser").val();
			//alert($("#typeUser").val());
			table.render({
				elem: '#user-name-label'
				, url: '/api-front/employer/getFrontServiceListByUname' //数据接口
				, page: true //开启分页
				, limit: 6
				, where: {
					"uname": uname,
                    "sid":sid

				}
				, response: {
					countName: 'count', //规定数据总数的字段名称，默认：count
					dataName: 'datas' //规定数据列表的字段名称，默认：data
				}
				, cols: [
					[ //表头
						{title:'序号',type:'numbers',width:'5%'}
						,{field: 'uid', title: 'ID', align: 'center',hide:true}
						, {field: 'uaccount', title: '账号',width:'13%'}
						, {field: 'uname', title: '昵称',width:'12%'}
						, {field: 'uphone', title: '联系方式',width:'12%'}
						, {field: 'uscore', title: '信用',align: 'center',sort:true,width:'7%'}
						, {field: 'uaddress', title: '地址',width:'15%'}
						, {field: 'usex', title: '性别',align: 'center',width:'5%'}
						// , {field: 'pid', title: '状态',width:'8%',align: 'center',templet:function (st) {
						// 	return st.pid== '1'?"启用":"禁用";
						// }}
						,{field: 'tips1', title: '状态',width:'8%',align: 'center'}
						, {field: 'tips2', title: '类型',width:'8%',align: 'center'}

						, {title: '操作', toolbar: '#barDemo',width:'22%',align: 'center'}
					]
				]
			});
			return false;
		});

		//checkPermission();

	});

	</script>
</body>
<script>




	// 添加服务商类型
	$(function () {
		$.ajax({
			url: "/user/service",
			data: {},
			dataType: "json",
			success: function (results) {
				$("#typeUser").empty();

				if (results != 0) {
					$("#typeUser").append(new Option("---请选择---", ""));
					$.each(results, function (index, item) {
						$('#typeUser').append(new Option(item.sname,item.sid));

					});
				} else {
					$("#typeUser").append(new Option("暂无数据", ""));
				}
				layui.form.render("select");
			}
		})
	});
</script>

